<?php

$date		= gpc_getStringGet("date");

List_Trankings($date);

function List_Trankings($date="")
{
    global $trackings;
    global $dbsql;

    $trackings=array();
    //-----------------------------------------------------
    $sql_where = " from tbltracking ";
    if(!empty($date) && $date!=-1)$sql_where.=" where dDate='$date' ";


    $sql_select = "select count(iAccountId) as count  ".$sql_where;
	$result = $dbsql->query_fetch($sql_select);
	$count_all=$result['count'];
	list($limit_st,$limit_le)	=Slit_Page($count_all);

    //-----------------------------------------------------
	$sql_select = "select * ".$sql_where;
	$sql_select.=" order by iTrackingId DESC limit $limit_st,$limit_le";
	$rs=$dbsql->query($sql_select);
	while ( $result = $dbsql->fetch_array($rs) )
	{
		$trackings[] = $result;
	}
	return  $trackings;
}

function List_Date()
{
	 global $date,$dbsql;
      //-----------------------------------------------------
      $sql_select = "select Distinct(dDate) from tbltracking order by dDate DESC";

      $rs=$dbsql->query($sql_select);
      $return = "<option value='-1'>Chose Date</option>";
      while ( $result = $dbsql->fetch_array($rs) )
      {
      	if($date == $result["dDate"])
      		$return .= "<option selected value='".$result["dDate"]."'>".$result["dDate"]."</option>";
      	else
      		$return .= "<option value='".$result["dDate"]."'>".$result["dDate"]."</option>";
      }
      return $return;


}

function Admin_info($iAccountId)
{
	global $datelist,$date_count,$date;

      global $dbsql;
      //-----------------------------------------------------
      $sql_select = "select * from tblaccount where iAccountId = $iAccountId";

      $rs=$dbsql->query($sql_select);
      $rows = $dbsql->num_rows($rs);


      if ($rows > 0)
      {
      	$result = $dbsql->fetch_array($rs);
      	$return = $result["cName"];
      }
      return $return;
}
?>